package com.site.mapper;


import com.night.common.entity.logistical.Appointment;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * @ClassName: Appointment
 * @author: LJC
 * @date: 2022/10/19-16:20
 * 场地预约表
 */
public interface AppointmentMapper {

    //查询所有信息
    List<Appointment> getAll();

    //新增预约信息
    void addAppointment(Appointment appointment);

    //修改预约信息
    void updateAppointment(Appointment appointment);

    //根据场地id查询预约信息
    Appointment getAppointmentById(Appointment appointment);

    //根据用户id查询
    @Select("SELECT * FROM ss_appointment WHERE user_id = #{userId}")
    @Results(id="appointmenttMap",value=
            {
                    @Result(property = "id",column = "id",id = true,jdbcType= JdbcType.INTEGER),
                    @Result(property = "userId",column = "user_id",jdbcType= JdbcType.INTEGER),
                    @Result(property = "userName",column = "user_name",jdbcType= JdbcType.CHAR),
                    @Result(property = "userPhone",column = "user_phone",jdbcType= JdbcType.CHAR),
                    @Result(property = "siteId",column = "site_id",jdbcType= JdbcType.INTEGER),
                    @Result(property = "appointmentDate",column = "appointment_date",jdbcType= JdbcType.DATE),
                    @Result(property = "startTime",column = "start_time",jdbcType= JdbcType.DATE),
                    @Result(property = "endTime",column = "end_time",jdbcType= JdbcType.DATE)
            })
    List<Appointment> getAppointmentByUserId(Appointment appointment);
}
